<?php
include("../../inc/psa_conect.php");
if ($_REQUEST["boton"] == "actualiza" and $_REQUEST["id"]== 0){
    $boton = "agrega";
}else{
    $boton = $_REQUEST["boton"];
}
if ($boton == "actualiza"){
   $sql  = "UPDATE proyectos SET ";
   $sql .= "idProyecto = '".$_REQUEST["idProyecto"]."', ";
   $sql .= "Company    = '".$_REQUEST["Company"]."', ";
   $sql .= "idCompany  = '".$_REQUEST["idCompany"]."', ";
   $sql .= "Person     = '".$_REQUEST["Person"]."', ";
   $sql .= "Name       = '".$_REQUEST["Name"]."', ";
   $sql .= "Type       = '".$_REQUEST["Type"]."', ";
   $sql .= "DateOp     = '".$_REQUEST["DateOp"]."', ";
   $sql .= "Emissions  = '".$_REQUEST["Emissions"]."', ";
   $sql .= "Quantity   = '".$_REQUEST["Quantity"]."', ";
   $sql .= "Crediting  = '".$_REQUEST["Crediting"]."', ";
   $sql .= "Investment = '".$_REQUEST["Investment"]."', ";
   $sql .= "Missing    = '".$_REQUEST["Missing"]."', ";
   $sql .= "StatNow    = '".$_REQUEST["StatNow"]."', ";
   $sql .= "StatNext   = '".$_REQUEST["StatNext"]."', ";
   $sql .= "StatFinal  = '".$_REQUEST["StatFinal"]."', ";
   $sql .= "Contacted  = '".$_REQUEST["Contacted"]."', ";
   $sql .= "OfferSent  = '".$_REQUEST["OfferSent"]."', ";
   $sql .= "Rejected   = '".$_REQUEST["Rejected"]."', ";
   $sql .= "Notes      = '".$_REQUEST["Notes"]."' ";
   $sql .= " WHERE id=".$_REQUEST["id"];
} else {
   if ($boton == "elimina"){
      $sql = "delete from proyectos WHERE id=".$_REQUEST["id"];
   } else {
      if ($boton == "agrega"){
         $sql  = "INSERT INTO proyectos (id, idProyecto, Company, idCompany, Person, Name, Type, DateOp, Emissions, Quantity, Crediting, Investment, Missing, StatNow, StatNext, StatFinal, Contacted, OfferSent, Rejected, Notes) ";
         $sql .= "VALUES (NULL, '".$_REQUEST["idProyecto"]."', '".$_REQUEST["Company"]."', '".$_REQUEST["idCompany"]."', '".$_REQUEST["Person"]."', '".$_REQUEST["Name"]."', '".$_REQUEST["Type"]."', '".$_REQUEST["DateOp"]."', '".$_REQUEST["Emissions"]."', '".$_REQUEST["Quantity"]."', '".$_REQUEST["Crediting"]."', '".$_REQUEST["Investment"]."', '".$_REQUEST["Missing"]."', '".$_REQUEST["StatNow"]."', '".$_REQUEST["StatNext"]."', '".$_REQUEST["StatFinal"]."', '".$_REQUEST["Contacted"]."', '".$_REQUEST["OfferSent"]."', '".$_REQUEST["Rejected"]."', '".$_REQUEST["Notes"]."')";
      }
   }
}
$result = mysql_query($sql,$link);
//echo $sql;
header("location: ../../index.php?psa_modulo=".$_REQUEST["psa_modulo"]);
?>